#include<bits/stdc++.h>
using namespace std;
#define INF 0xFFFFFFFF
int arr[10001];
int N,a,b,t;

int main(){
	cin>>N;
	while(N--){
		cin>> a>>b>>t;
		arr[0]=a;arr[1]=b;
		for(int i=2;i<t;i++) {
		if(i%2==0)arr[i]= arr[i-1]+arr[i-2];
		else arr[i]= arr[i-1]+arr[i-2]+arr[i-3];
		}
		printf("%d\n",arr[t-1]);
	}
	return 0;
}
